package com.code.day10.reflectss;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<Person> personClass = Person.class;
        Constructor<Person> constructor = personClass.getConstructor(String.class, int.class);
        Person p1 = constructor.newInstance("张三", 10);
        Method methods = personClass.getMethod("toString");
        Object o = methods.invoke(p1);
        System.out.println(o);
    }
}
